#pragma once

#include <vector>
#include "Block.h"

class Board : public QObject {
Q_OBJECT

public:
    explicit Board(QWidget *widget);

    ~Board() override;

    void reset(int r, int c, int n);

    Block *operator[](int x, int y);

    Block *get(int x, int y);

    std::vector<Block *> getNear(int x, int y);

    const int &g_r = m_r;
    const int &g_c = m_c;
    const int &g_n = m_n;

signals:
#pragma clang diagnostic push
#pragma ide diagnostic ignored "NotImplementedFunctions"

    void gameOver(bool win);

    void updateRemain(int remain);

    void updateHover(bool enter);

#pragma clang diagnostic pop

private slots:

    void onPress(Block *block);

    void onMark(Block *block);

    void onEnter(Block *block);

    void onLeave(Block *block);

private:
    void resize(int r, int c);

    void initPosition();

    void initMine(int n);

    void initNumber();

    int m_r = 0;
    int m_c = 0;
    int m_n = 0;
    bool is_game_over = false;
    QWidget *widget;
    std::vector<Block *> data;
};
